<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
    <style type="text/css">
        body, html, #allmap {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
        }
    </style>
    <script type="text/javascript"
            src="http://api.map.baidu.com/api?v=2.0&ak=6zLu4HrkmkQO52ojX0qXNZKqdOCpFX55"></script>
    <title>route</title>
</head>
<body>
<div id="allmap"></div>
</body>
</html>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
    var map = new BMap.Map("allmap");
    var point = new BMap.Point(123.16387, 41.683458);
    map.centerAndZoom(point, 15);
    map.addControl(new BMap.ScaleControl());
    map.addControl(new BMap.OverviewMapControl());
    map.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放
    $(function () {
        const ws = new WebSocket("ws://localhost:8080/v1/ws");
        ws.onmessage = function (e) {
            _jsonObj = JSON.parse(e.data);
            if (_jsonObj.data.coordinates === 1) {
                var point = new BMap.Point(_jsonObj.data.longitude, _jsonObj.data.latitude);
                var marker = new BMap.Marker(point); //将点转化成标注点
                map.clearOverlays();
                map.addOverlay(marker);  //将标注点添加到地图上
            }
        };
    });
</script>
